package day0812.huawei;


import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String s1 = s.replaceAll(" ", "")
                     .replace("[", "")
                     .replace("]", "");

        String[] s2 = s1.split(",");

        int [][] hash = new int[101][101];
        int[][] input = new int[s2.length/2][2];
        int k=0;

        for (int i = 0; i <s2.length/2 ; i++) {
            for (int j = 0; j <2 ; j++) {
                input[i][j] = Integer.parseInt(s2[k]);
                k++;
            }
            ++hash[input[i][0]][input[i][1]];
        }

        int max=0;
        int [][] dp = new int[101][101];
        for (int i = 1; i <101 ; i++) {
            for (int j = 1; j <101 ; j++) {
                int comp = (dp[i-1][j]>dp[i][j-1])?dp[i-1][j]:dp[i][j-1];
                dp[i][j]= comp+hash[i][j];
                if (dp[i][j]>max){
                    max =dp[i][j];
                }
            }
        }
        System.out.println(max);
    }

}
